package cn.flying.base.sys.service;

import javax.annotation.Resource;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.flying.base.sys.domain.SysUser;
import cn.flying.base.sys.domain.SysUserRole;
import cn.flying.base.sys.mapper.SysUserMapper;

/**
 * @description:
 * @author: lvyong
 * @date: 2023年05月24日 13:12
 * @version: 1.0
 */
@Service
public class SysUserService {

    @Resource
    private SysUserMapper sysUserMapper;


    /**
     * 通过用户名查询用户
     *
     * @param username
     * @return
     */
    public SysUser findUserByUsername(String username) {
        return sysUserMapper.findUserByUsername(username);
    }

    /**
     * 通过用户ID查询用户角色权限
     *
     * @param userId
     * @return
     */
    public List<SysUserRole> getUserRoleList(String userId) {
        return sysUserMapper.getUserRoleList(userId);
    }

    /**
     * 更新用户的最后登录时间
     * @param username
     */
    @Transactional(rollbackFor = Exception.class)
    public void updateUserLoginTimeByUsername(String username) {
        sysUserMapper.updateUserLoginTimeByUsername(username);
    }
}
